﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace PROJECT_BOMBER.BLL
{
    public class Piece : ElementPhysique, ICloneable
    {
        public Piece(int x, int y, int value) : base(x, y)
        {
            CollisionStrategy = new PieceCollision();
            Valeur = value;
            Catch = false;
        }
        int _valeur;

        bool _catch;

        public bool Catch
        {
            get { return _catch; }
            set { _catch = value; }
        }

        public int Valeur
        {
            get { return _valeur; }
            set { _valeur = value; }
        }


        public override void Update(Level level)
        {
            if (!Catch)
            {
                _position.X = level.Position.X + _positionbase.X;
                _position.Y = level.Position.Y + _positionbase.Y;

                Onscreen();

                if (Visible)
                {
                    Case = new Rectangle((int)_position.X, (int)_position.Y, (int)Width, (int)Height);
                    CurrentAnimation.Update(Case.X, Case.Y);
                }


                }            
        }

        public override void DrawAnimation()
        {
            if (!Catch)
            {
                if (Visible)
                {
                    CurrentAnimation.Draw();
                }
            }
        }


        #region ICloneable Membres

        public object Clone()
        {
            Piece piece = new Piece((int)this.Position.X, (int)this.Position.Y, this.Valeur);
            foreach (KeyValuePair<string, AnimationSprite> value in this.Animations)
            {
                piece.AddAnimation(value.Key, value.Value);
            }
            return piece;
        }

        #endregion
    }
}
